/* $Id: JMapContextMenuUnitTest.java 60 2010-02-01 19:54:35Z aaron.day $ */
package org.crazydays.gameplan.map.swing;


import javax.swing.JMenuItem;
import javax.swing.JPopupMenu.Separator;

import org.junit.*;
import static org.junit.Assert.*;

import org.crazydays.gameplan.map.action.OpenMapPropertiesDialog;
import org.crazydays.gameplan.map.action.ToggleGrid;

/**
 * JMapContextMenuUnitTest
 */
public class JMapContextMenuUnitTest
{
    /**
     * Test initialize().
     */
    @Test
    public void testInitialize()
    {
        // objects
        ToggleGrid toggleGrid = new ToggleGrid();
        OpenMapPropertiesDialog openMapPropertiesDialog =
            new OpenMapPropertiesDialog();

        // setup
        JMapContextMenu menu = new JMapContextMenu();
        menu.setToggleGrid(toggleGrid);
        menu.setOpenMapPropertiesDialog(openMapPropertiesDialog);

        // test
        menu.initialize();

        // verify
        assertEquals("components", 3, menu.getComponentCount());
        assertTrue("toggleGrid", menu.getComponent(0) instanceof JMenuItem);
        assertEquals("toggleGrid", toggleGrid, ((JMenuItem) menu
            .getComponent(0)).getAction());
        assertTrue("separator", menu.getComponent(1) instanceof Separator);
        assertTrue("openMapPropertiesDialog",
            menu.getComponent(2) instanceof JMenuItem);
        assertEquals("openMapPropertiesDialog", openMapPropertiesDialog,
            ((JMenuItem) menu.getComponent(2)).getAction());
    }
}
